package Utils;

public class ArrayUtils {
    //随机生成长度为amount，元素最大为max的数组
    public static int[] generateArray(int amount, int max) {
        int[] arr = new int[amount];
//        int max = 100;
        for (int i = 0; i < amount; i++) {
            arr[i] = ((int) ((Math.random() * max) + 1)) - (max >> 1);
        }
        return arr;
    }

    //交换数组元素
    public static void swap(int[] arr, int i1, int i2) {
        int temp = arr[i1];
        arr[i1] = arr[i2];
        arr[i2] = temp;
    }
}
